#include <stdio.h>
#include <math.h>
#include <stdlib.h>

//https://www.nowcoder.com/practice/d3a404ee0f8d41f98bf4707035d91086?tpId=290&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D290

int main() {
    int min = 0;
    int max = 0;
    int num = 0;
    printf("请输入数据:>");
    scanf("%d%d", &min, &max);
    min = min <= 2 ? 2 : min;
    int *STP = (int *) calloc(max, sizeof(int));
    if (STP == NULL) {
        perror("堆区开辟失败");
    }
    for (int i = min; i <= max; i++) {
        for (int j = 2; j <= sqrt(i); j++) {
            if (STP[j] == 0 && i % j == 0) {
                STP[i] = 1;
                break;
            }
        }
        if (STP[i] == 0) {
            num++;
            printf("%d ", i);
        }
    }
    printf("\n%d", num);
    free(STP);
    STP = NULL;
    return 0;
}
